/**
 * Copyright (c) Software Institute of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.edit.parts;

import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartFactory;

import edu.pku.sei.modeler.model.structure.MetaDiagram;
import edu.pku.sei.modeler.model.structure.MetaShapeElement;


/**
 * @author xy
 *
 */
public abstract class AbstractTreeEditPartFactory implements EditPartFactory{

    public EditPart createEditPart(EditPart context, Object model) {
    	EditPart part = null;

		if (model instanceof MetaDiagram)
			part = new DiagramTreeEditPart((MetaDiagram)model);
		else if (model instanceof MetaShapeElement)
			part = createEditPart((MetaShapeElement)model);
		if(part != null)
			part.setModel(model); 
	    return part;
    }
    
    public EditPart createEditPart(MetaShapeElement model)
	{
    	return new DefaultTreeEditPart(model);
//		EditPart part = null;
//		MetaElement content = shape.getModelElement();
//		if(content instanceof MetaClass) {
//			boolean inter = ((MetaClass)content).isInterface();
//			if(inter) {
//				part = new TemplateInterfaceTreeEditPart(shape);
//			}
//			else {
//				part = new MetaClassTreeEditPart(shape);
//			}
//		} 
////		else if(content instanceof edu.pku.modeler.model.uml.interfaces.Interface) {
////			part = new UMLInterfaceTreeEditPart((AbstractModel)model);
////		} 
//		else if(content instanceof MetaComment) {
//			part = new MetaCommentTreeEditPart(shape);
//		} 
//		else if(content instanceof MetaPackage) {
//			part = new MetaPackageTreeEditPart(shape);
//		}
//		else if(content instanceof TemplateNode) {
//			part = new TemplateNodeTreeEditPart(shape);
//		}
//		else if(content instanceof TemplatePort) {
//			part = new TemplatePortTreeEditPart(shape);
//		}
//		return part;
	}
}